package Test;

import static org.junit.Assert.*;

import org.junit.Test;

import borderPatrol.misc.Judge;

public class JudgeTest {

	@Test
	public void isTerminalTestWithArraysAndTwoExpected() {
		
		int[] poacherPosition = new int[]{1, 1};
		int[] patrollerPosition = new int[]{1, 1};
		int[] lastPoacherPosition = new int[]{0, 1};
		int[] lastPatrollerPosition = new int[]{2, 1};
		
		assertEquals(2, Judge.getInstance().isTerminal(poacherPosition, patrollerPosition, lastPoacherPosition, lastPatrollerPosition));
	}
	
	@Test
	public void isTerminalTestWithArraysAndTwoExpectedEdgeCollision() {
		
		int[] poacherPosition = new int[]{1, 1};
		int[] patrollerPosition = new int[]{0, 1};
		int[] lastPoacherPosition = new int[]{0, 1};
		int[] lastPatrollerPosition = new int[]{1, 1};
		
		assertEquals(2, Judge.getInstance().isTerminal(poacherPosition, patrollerPosition, lastPoacherPosition, lastPatrollerPosition));
	}	

	@Test
	public void isTerminalTestWithArraysAndOneExpected() {
		
		int[] poacherPosition = new int[]{3, 3};
		int[] patrollerPosition = new int[]{2, 0};
		int[] lastPoacherPosition = new int[]{2, 2};
		int[] lastPatrollerPosition = new int[]{2, 1};
		
		assertEquals(1, Judge.getInstance().isTerminal(poacherPosition, patrollerPosition, lastPoacherPosition, lastPatrollerPosition));
	}
	
	@Test
	public void isTerminalTestWithArraysAndZeroExpected() {
		
		int[] poacherPosition = new int[]{1, 1};
		int[] patrollerPosition = new int[]{2, 0};
		int[] lastPoacherPosition = new int[]{0, 0};
		int[] lastPatrollerPosition = new int[]{2, 1};
		
		assertEquals(0, Judge.getInstance().isTerminal(poacherPosition, patrollerPosition, lastPoacherPosition, lastPatrollerPosition));
	}
	
	@Test
	public void isTerminalTestWithStringsAndZeroExpected() {
			
		String poacherId = "1.00";
		String patrollerId = "2.22";
		
		assertEquals(0, Judge.getInstance().isTerminal(poacherId, patrollerId));
	}
	
	@Test
	public void isTerminalTestWithStringsAndZeroExpectedOne() {
			
		String poacherId = "1.00.01";
		String patrollerId = "2.22.12";
		
		assertEquals(0, Judge.getInstance().isTerminal(poacherId, patrollerId));
	}
	
	@Test
	public void isTerminalTestWithStringsAndTwoExpected() {
			
		String poacherId = "1.00.01";
		String patrollerId = "2.20.01";
		
		assertEquals(2, Judge.getInstance().isTerminal(poacherId, patrollerId));
	}
	
	@Test
	public void isTerminalTestWithStringsAndTwoExpectedEdge() {
			
		String poacherId = "1.01.00.01";
		String patrollerId = "2.20.01.00";
		
		assertEquals(2, Judge.getInstance().isTerminal(poacherId, patrollerId));
	}
	
	@Test
	public void isTerminalTestWithStringsAndOneExpected() {
			
		String poacherId = "1.00.10.20.33";
		String patrollerId = "2.20.21.22.21";
		
		assertEquals(1, Judge.getInstance().isTerminal(poacherId, patrollerId));
	}

}
